Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.toDecimalMark = exports.sumBy = exports.sum = exports.subNum = exports.round = exports.randomNum = exports.mulNum = exports.divNum = exports.addNum = void 0;

exports.randomNum = function(t, r) {
    return Math.floor(Math.random() * (r - t + 1)) + t;
};

exports.round = function(t) {
    var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
    return Number("".concat(Math.round("".concat(t, "e").concat(r)), "e-").concat(r));
};

var t = function(t, e) {
    return t.map("function" == typeof e ? e : function(t) {
        return t[e];
    }).reduce(function(t, e) {
        return r(t, e);
    }, 0);
};

exports.sumBy = t;

exports.sum = function(r) {
    return t(r, function(t) {
        return t;
    });
};

exports.toDecimalMark = function(t) {
    var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "";
    return t.toLocaleString("en-US").replace(/^/, r);
};

var r = function(t, r) {
    var n, o, u;
    try {
        n = t.toString().split(".")[1].length;
    } catch (t) {
        t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
        n = 0;
    }
    try {
        o = r.toString().split(".")[1].length;
    } catch (t) {
        t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
        o = 0;
    }
    return u = Math.pow(10, Math.max(n, o)), (e(t, u) + e(r, u)) / u;
};

exports.addNum = r;

exports.subNum = function(t, r) {
    var n, o, u;
    try {
        n = t.toString().split(".")[1].length;
    } catch (t) {
        t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
        n = 0;
    }
    try {
        o = r.toString().split(".")[1].length;
    } catch (t) {
        t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
        o = 0;
    }
    return u = Math.pow(10, Math.max(n, o)), (e(t, u) - e(r, u)) / u;
};

var e = function(t, r) {
    var e = 0, n = t.toString(), o = r.toString();
    try {
        e += n.split(".")[1].length;
    } catch (t) {}
    try {
        e += o.split(".")[1].length;
    } catch (t) {}
    return Number(n.replace(".", "")) * Number(o.replace(".", "")) / Math.pow(10, e);
};

exports.mulNum = e;

exports.divNum = function(t, r) {
    var n, o, u = 0, a = 0;
    try {
        u = t.toString().split(".")[1].length;
    } catch (t) {}
    try {
        a = r.toString().split(".")[1].length;
    } catch (t) {}
    return n = Number(t.toString().replace(".", "")), o = Number(r.toString().replace(".", "")), 
    e(n / o, Math.pow(10, a - u));
};